package simpledataset;

import randomwalk.PreferencesVector;
import lastfm.LastfmUserUserSubmatrix;
import lastfm.LastfmUserTrackSubmatrix;
import musictrackrecommendation.Dataset;

public class SimpleMatrix implements Dataset{
	private static int[] userIds =   {0,0,0,1,1,2,2,3,4,4,4};
	private static int[] friendIds = {1,2,4,0,4,0,3,2,0,1,2};
	private static double[] values = {0.5,0.2,0.2,0.4,0.4,0.2,(1.0/6.0),0.2,0.2,0.4,0.2};
	
	private static int[] userIdList  = {0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4};
	private static int[] trackIdList = {1,2,6,11,12,3,6,8,11,14,1,3,7,10,13,0,2,5,9,10,12,0,1,4,8,14};
	private static double [] valuesList = {1,3,2,1,2,1,1,3,1,3,2,2,2,1,3,2,2,3,2,4,4,2,1,4,1,2};
	/**
	 * @return the userUser
	 */
	public static LastfmUserUserSubmatrix getUserUser() {
		LastfmUserUserSubmatrix userUser = 
			new LastfmUserUserSubmatrix(userIds, friendIds, values, values.clone());
		return userUser;
	}

	/**
	 * @return the userTrack
	 */
	public static LastfmUserTrackSubmatrix getUserTrack() {
			LastfmUserTrackSubmatrix userTrack = 
			new LastfmUserTrackSubmatrix(userIdList, trackIdList, valuesList, valuesList.clone());
		return userTrack;
	}
	
	/**
	 * Friends of given user
	 * @param userId - id of interesting user
	 * @return array with 1.0 for friends of given user
	 */
	public static double[] getFriendPreferences(int userId) {
		double[] friends = new double[5];
		for (int i = 0; i < userIds.length; i++) {
			if(userIds[i] == userId) 
				friends[friendIds[i]]=1.0;
		}
		return friends;	
	}
	
	/**
	 * Tracks of given user
	 * @param userId - id of interesting user
	 * @return array with 1.0 for tracks of given user
	 */
	public static double[] getTrackPreferencess(int userId) {
		double[] tracks = new double[15];
		for (int i = 0; i < userIdList.length; i++) {
			if(userIdList[i] == userId) 
				tracks[trackIdList[i]]=1.0;
		}
		return tracks;	
	}

	@Override
	public PreferencesVector getRestartVector(int userId) {
		PreferencesVector restartVector = 
			new PreferencesVector(
					getFriendPreferences(userId),
					getTrackPreferencess(userId),
					new double[0]);
		return restartVector;
	}

	@Override
	public int getTracksMaximalId() {
		return 14;
	}

	@Override
	public int[] getUserList() {
		return new int[] {0,1,2,3,4};
	}

	@Override
	public int getUserTrackCount() {
		return 26;
	}

	@Override
	public int getUserUserCount() {
		return 11;
	}

	@Override
	public int getUsersMaximalId() {
		return 4;
	}

	@Override
	public int getUsersCount() {
		return 5;
	}

	@Override
	public int getTrackTrackCount() {
		// TODO Auto-generated method stub
		return 0;
	}
}
